<% content_for :stylesheet_head do %>
        <style>
          .bu,button.button,tr td button {
                padding: 2px 10px;
                margin: 0px 10px;
                background: #009bce;
                border-radius: 4px;
                border: 1px;
                color: #fff;
            }
        </style>
<% end %>
<!-- 新增隐藏框 -->
<div class="modal fade" id="Modal" tabindex="-1" role="dialog" aria-labelledby="ModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="ModalLabel">报警详情</h4>
      </div>
        <%= form_tag('aa', method: :post, :class=>"form-horizontal") do %>
              <div class="modal-body">
                      <table class="table  list_table">
                        <tbody>
                                <tr>
                                    <td>
                                        时间:
                                    </td>
                                    <td>
                                       <span id="time"></span>
                                    </td>                                    
                                </tr> 
                                <tr>
                                    <td>
                                        地址:
                                    </td>
                                    <td>
                                        <span id="address"></span>
                                    </td>                                    
                                </tr>                                
                                <tr>
                                    <td>
                                        报警内容:
                                    </td>
                                    <td>
                                       <span id="message"></span>
                                    </td>                                    
                                </tr>                                
                               
                        </tbody>
                      </table>
             </div>

            <div class="modal-footer">
                <button type="reset" class="btn btn-default" data-dismiss="modal">
                             关闭
                </button>             
              </div>
          </div>
   <% end %>
     <div class="WhereToLinks"></div>
  </div>
</div>
<!-- 新增隐藏框结束 -->
    <div class="listFilter" style="margin: 20px;">
      <h2>报警审核</h2>
      <div class="divider"></div>
       <%= form_for_filterrific @filterrific do |f| %>
            <table style="width: 100%;" class="list_table">
                  <tbody>
                    <tr>
                        <td>姓名:</td><td><%= f.text_field   :with_name %></td>
                        <td>开始时间:</td><td><%= f.text_field :with_upload_time_begin,onclick:"SelectDate(this,'yyyy-MM-dd hh:mm:ss')"%></td>                        
                        <td>结束时间:</td> <td><%= f.text_field :with_upload_time_end,onclick:"SelectDate(this,'yyyy-MM-dd hh:mm:ss')"%></td>   
                    </tr>
                    <tr>                       
                       <td>手机:</td><td><%= f.text_field   :with_phone %></td>                        
                       <td>状态:</td><td><%= f.select  :with_status,[['全部',''],['未审核','未审核'],['已审核','已审核']] %></td> 
                        <td><%= f.submit "查询", :class=>"button" %></td> 
                    </tr>
                  </tbody>
            </table>
        <% end %>
      <div class="list_table" >
        <table class="bb list_table"  cellspacing="0" style="text-align:left" >
          <thead>
            <tr>
              <th width='1%'>序号</th>
              <th width='1%'>姓名</th>
              <th width='1%'>手机号</th>
              <th width='1%'>地址</th>
              <th width='1%'>状态</th>
              <th width='1%'>登记时间</th>
              <th width='1%'>审核人</th>
              <th width='1%'>操作</th>
            </tr>
          </thead>
          <tbody id="tbody">
          <%  if @alarm_data != nil
             odd_or_even = 0
             tmp=0
            @alarm_data.each do |hotels|
               tmp = tmp+1
          -%>
                  <tr class="odd_row">
                      <td><%= h(tmp) %></td>
                      <td><%= hotels.name %></td>
                      <td><%= hotels.phone %></td>
                      <td><%= hotels.address %></td>
                      <td><%= hotels.status %></td>
                      <td><%= hotels.created_at.strftime("%Y-%m-%d %H:%M:%S") %></td>
                      <td><%= hotels.check_person %></td>
                      <td >  
                        <% if  hotels.status=='未审核' %>                
                          <%= link_to "审核",alarm_record_path(hotels),{style:"color:red",method: :delete, data: { confirm: '通过审核?' } } %>
                        <%else%>
                           已审核
                        <%end%>
                        <a href="javascript:" data-toggle="modal" data-target="#Modal" onclick="edit_load(<%=hotels.id%>);" style="color:red">
                         详情
                       </a>
                    </td>
                 </tr>
            <% end %>
            <% end %>
          <tr>
            <td colspan="9">
               <%= will_paginate(@alarm_data ,:previous_label=>'上一页',:next_label=>'下一页')  %>
            </td>
         </tr>
          </tbody>
        </table>
        <div class="WhereToLinks"></div>
      </div>
    </div>
    <% content_for :javascript_head do %>  
       <script type="text/javascript">
                      function edit_load(id){                             
                               $("form[action='aa']")[0].reset();
                               var url="/alarm_record/alarm_ajax?a="+id;                                
                                $.ajax({url:url,
                                        async:false,
                                        type: "get",
                                        success:function(r){                          
                                              aa=JSON.parse(r);                                              console.log(aa);
                                                for (cc in aa)
                                                {
                                                  console.log(aa[cc]);
                                                }
                                              if ( aa!=null   )   
                                                  { 
                                                     $("#time").text(aa.created_at);  
                                                     $("#address").text(aa.address);             
                                                     $("#message").text(aa.message);
                                                  } 
                                              else
                                                 {  alert("数据错误请刷新!");  }
                                                          }
                                      })
                      }
        </script>
    <% end %>
